import 'package:flutter/material.dart';
import 'package:wallpaper/components/my_bottom_navbar.dart';
import 'package:wallpaper/pages/navbar/food_page.dart';
import 'package:wallpaper/pages/navbar/home_page.dart';
import 'package:wallpaper/pages/navbar/setting_page.dart';
import 'package:wallpaper/pages/navbar/vidoe_page.dart';

class MainPage extends StatefulWidget {
  const MainPage({super.key});

  @override
  State<MainPage> createState() => _HomePageState();
}

class _HomePageState extends State<MainPage> {
  int selectIndex = 0;
  List<Widget> pages = [HomePage(), VideoPage(), FoodPage(), SettingPage()];
  void changeTabbar(int index) {
    setState(() {
      selectIndex = index;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      extendBody: true, // 扩展到Scaffold的底部
      resizeToAvoidBottomInset: false, // 不允许键盘事件影响界面
      body: IndexedStack(
        index: selectIndex,
        children: pages,
      ),
      bottomNavigationBar: MyBottomNavBar(
        selectIndex: selectIndex,
        changeTabbar: changeTabbar,
      ),
    );
  }
}
